package com.fun.feifun.modules.business.model.dto;

import com.fun.feifun.base.BaseEntity;
import com.fun.feifun.base.utils.MD5Util;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.experimental.Accessors;

/**
 * <p>
 * 系统用户
 * </p>
 *
 * @author wkf
 * @since 2024-06-04
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class BusinessPlaceOrderDto extends BaseEntity {
    private static final long serialVersionUID=1L;


    @ApiModelProperty(value = "用户编码")
    @NonNull
    private String businessUserCode;


    @ApiModelProperty(value = "商品编码")
    @NonNull
    private String goodsCode;


    @ApiModelProperty(value = "充值目标账号(手机号)")
    @NonNull
    private String rechargeAccount;


    @ApiModelProperty(value = "充值金额（面值）整数 （需要和商品金额一致）")
    @NonNull
    private Integer price;

    //sign=MD5(userid=xxxx&productid=xxxxxxx&price=xxxx&num=xxx&mobile=xxxxx&spordertime=xxxxxxx&sporderid=xxxxx&key=xxxxxxx).toUpperCase()

    @ApiModelProperty(value = "签名验证摘要串：MD5(businessUserCode=xxxx&goodsCode=xxxxxxx&rechargeAccount=xxxx&price=xxxxx&&key=xxxxxxx)")
    @NonNull
    private String sign;

    @ApiModelProperty(value = "密匙")
    @NonNull
    private String secretKey;

    @ApiModelProperty(value = "时间戳")
    private Long timeStamp;

    @ApiModelProperty(value = "回调接口地址")
    private String backUrl;

    public String MD5Sign() {
        String encrypt ="";
        try {
            StringBuilder signStr = new StringBuilder();
            signStr.append("businessUserCode="+this.getBusinessUserCode()+"&&");
            signStr.append("goodsCod="+this.getGoodsCode()+"&&");
            signStr.append("rechargeAccount="+this.getRechargeAccount()+"&&");
            signStr.append("price="+this.getPrice()+"&&");
            signStr.append("secretKey="+this.getSecretKey()+"&&");
            signStr.append("timeStamp="+this.getTimeStamp());
            encrypt = MD5Util.encrypt(signStr.toString());
        }catch (Exception e){
            e.printStackTrace();
        }
        return encrypt;
    }
}
